app.controller("wstatistics",function($scope,$uibModal,$rootScope,del,$state,get,$stateParams){
	$scope.colorPer=['5D9EFF','54D3AE','FFC066']
	$scope.tType=''
	$scope.typess=''
	get.list("dictionary/project").then(function(e){
			$scope.itemArray=e
			$scope.itemArray.unshift({
						diName:"请选择项目",
						diId:-1
					})
			$scope.selected={
						value:{
							diName:"请选择项目",
							diId:null
						}
					}
			})
	get.list("taskP/countPA",{}).then(function(e){
				$scope.workNum=e.workNum;
				$scope.maintenanceNum=e.maintenanceNum
				$scope.projectNum=e.projectNum
				$scope.freeNum=e.freeNum
				$scope.projectTotalNum=e.projectTotalNum
				$scope.maintenanceTotalNum=e.maintenanceTotalNum
					$scope.i=0
		$scope.lineConfig = {
	            theme:'macarons',
	            dataLoaded:true
	        };
	$scope.lineOptionsage = {  
    tooltip : {  
        trigger: 'item',  
        formatter: "{a} <br/>{b} : {c} ({d}%)"  
    },  
    legend: {  
        orient : 'vertical',  
        x : 'left',  
        data:['女','男']  
    },
    series : [  
        {  
            name:'人员情况',  
            type:'pie',  
            radius : ['30%', '70%'],  
            avoidLabelOverlap: false,
label: {
                normal: {
                    show: false,
                    position: 'center'
                },
                emphasis: {
                    show: false,
                    textStyle: {
                        fontSize: '14',
                        fontWeight: 'bold'
                    }
                }
           },
            data: [
                {value: $scope.maintenanceNum, name: '维护中人数',itemStyle : {normal : {color :'#5D9EFF'}}},
                {value: $scope.projectNum, name: '项目中人数',itemStyle : {normal : {color :'#54D3AE'}}},
                {value: $scope.freeNum, name: '空闲人数',itemStyle : {normal : {color :'#FFC066'}}},
                
            ] 
        }  
    ]  
};  
			})


		$scope.sta=0;
		$scope.search=function(i,a){
			
			var tProId=''
			if($scope.selected!=null){
				tProId=$scope.selected.value.diId
			}
			console.log(tProId)
			var param={
				pageNum:i||'1',
				pageSize:6,
				tDesigneeId:a||'',
				tStartTime:$scope.startTime||'',
				tEndTime:$scope.endTime||'',
				tType:$scope.tType,
				type:$scope.typess,
				tProId:tProId||''
			}
			var url="taskP/staffA"
			if($scope.sta==0){
				url="taskP/staffA"
			}else if($scope.sta==1){
				url="taskP/staffXA"
			}else if($scope.sta==2){
				url="taskP/detailsA"
			}
		get.list(url,param).then(function(e){
				$scope.list=e.list
				$scope.pageSize = e.pageSize; //每页多少条
				$scope.totalNum = e.pageCount; //总共多少页
				$scope.totalSize =e.totalNums; //总共多少条   
				$scope.pageNum = e.pageNum; //当前页面
			})
		}
		$scope.search();
		$scope.tTypes=function(i){
			$scope.sta=0;
			$scope.typess=''
			if(i==0){
				$scope.tType=i
			}else{
				$scope.tType=i||''
			}
			
			$scope.search(0);
		}
		$scope.clickP=function(i){
			$scope.sta=1;
			$scope.project=i
			$scope.search(0,i);
		}
		$scope.clickX=function(i){
			$scope.sta=2;
			$scope.tType=' '
			if(i==0){
				$scope.typess=i
			}else{
				$scope.typess=i||''
			}
			$scope.search(0);
		}
		$scope.fanhuix=function(i){
			$scope.sta=1
			$scope.search(0,i);
		}
		$scope.fanhui=function(i){
			$scope.sta=i
			$scope.search(0,i);
		}
		$scope.pageUp=function(){//跳转页码
       	if ($scope.tj.page>$scope.totalNum) {
       		$scope.tj.page=$scope.totalNum
       	} else if($scope.tj.page<1){
       	$scope.tj.page=null
       	}
       }//pageUp
   $scope.toPage=function(i){//点击跳转
       i=i||$scope.tj.page
       	$scope.search(i)
       	$scope.tj.current=$scope.tj.page;//页码调整
   }//toPage
   if($stateParams.page!=null){
			$scope.tj={
				page:$stateParams.page
			}
		 $scope.toPage($stateParams.page)
	}else{
			$scope.search();
	}

})
